public class Edge implements Comparable {

  int minX;
  int minY;
  int maxY;
  float m;

  public Edge(int x0, int y0, int x1, int y1) {
    int maxX;
    if (y0<y1) {
      minY = y0;                
      minX = x0;
      maxY = y1;
      maxX = x1;
    }
    else {
      minY = y1;
      minX = x1;
      maxY = y0;
      maxX = x0;
    }    
    m = (float)(minY-maxY)/(minX-maxX);
    println("Created edge with slope : " + m);
  }

  public void update() {
    minX += (int)floor(1.0f/m);
    minY++;
  }

  public int compareTo(Object obj) {

    Edge e2 = (Edge) obj;

    if (this.minY < e2.minY) {
      return -1;
    }
    else if (this.minY  == e2.minY) {
      if (this.minX < e2.minX) {
        return -1;
      }
      else if (this.minX == e2.minX) {
        if (this.m > e2.m) {
          return -1;
        }
        else if (this.m == e2.m) {
          return 0;
        }     
        else {
          return 1;
        }
      } 
      else {
        return 1;
      }
    }
    else {
      return 1;
    }
  }
}

